/*
# _____     ___ ____     ___ ____
#  ____|   |    ____|   |        | |____|
# |     ___|   |____ ___|    ____| |    \    PS2DEV Open Source Project.
#-----------------------------------------------------------------------
# Copyright (c) 2003 Marcus R. Brown <mrbrown@0xd6.org>
# Licenced under Academic Free License version 2.0
# Review ps2sdk README & LICENSE files for further details.
*/

/**
 * @file
 * ATA hardware types and definitions.
 */

#ifndef __ATAHW_H__
#define __ATAHW_H__

#include <tamtypes.h>
#include <aifregs.h>
#include <speedregs.h>

#define ATA_DEV9_HDD_BASE (SPD_REGBASE + 0x40)
/** AIF on T10Ks - supported with aifatad.  */
#define ATA_AIF_HDD_BASE  (AIF_REGBASE + AIF_ATA)

/** A port contains all of the ATA controller registers.  */
typedef struct _ata_hwport
{
    vu16 r_data;  /* 00 */
    vu16 r_error; /* 02 */
#define r_feature r_error
    vu16 r_nsector; /* 04 */
    vu16 r_sector;  /* 06 */
    vu16 r_lcyl;    /* 08 */
    vu16 r_hcyl;    /* 0a */
    vu16 r_select;  /* 0c */
    vu16 r_status;  /* 0e */
#define r_command r_status
    vu16 pad[6];
    vu16 r_control; /* 1c */
} ata_hwport_t;

#define USE_ATA_REGS ata_hwport_t *ata_hwport = \
                         (ata_hwport_t *)ATA_DEV9_HDD_BASE

#define USE_AIF_ATA_REGS ata_hwport_t *ata_hwport = \
                             (ata_hwport_t *)ATA_AIF_HDD_BASE

/* r_error bits.  */
#define ATA_ERR_MARK   0x01
#define ATA_ERR_TRACK0 0x02
#define ATA_ERR_ABORT  0x04
#define ATA_ERR_MCR    0x08
#define ATA_ERR_ID     0x10
#define ATA_ERR_MC     0x20
#define ATA_ERR_ECC    0x40
#define ATA_ERR_ICRC   0x80

/* r_status bits.  */
#define ATA_STAT_ERR   0x01
#define ATA_STAT_INDEX 0x02
#define ATA_STAT_ECC   0x04
#define ATA_STAT_DRQ   0x08
#define ATA_STAT_SEEK  0x10
#define ATA_STAT_WRERR 0x20
#define ATA_STAT_READY 0x40
#define ATA_STAT_BUSY  0x80

/* r_select bits.  */
#define ATA_SEL_LBA 0x40

/** ATA command codes.  */
enum ATA_C_CODES {
    ATA_C_NOP                             = 0x00,
    ATA_C_CFA_REQUEST_EXTENDED_ERROR_CODE = 0x03,
    ATA_C_DATA_SET_MANAGEMENT             = 0x06,
    ATA_C_DATA_SET_MANAGEMENT_XL          = 0x07,
    ATA_C_DEVICE_RESET                    = 0x08,
    ATA_C_REQUEST_SENSE_DATA_EXT          = 0x0B,
    ATA_C_RECALIBRATE                     = 0x10,
    ATA_C_RECALIBRATE_11H                 = 0x11,
    ATA_C_RECALIBRATE_12H                 = 0x12,
    ATA_C_RECALIBRATE_13H                 = 0x13,
    ATA_C_RECALIBRATE_14H                 = 0x14,
    ATA_C_RECALIBRATE_15H                 = 0x15,
    ATA_C_RECALIBRATE_16H                 = 0x16,
    ATA_C_RECALIBRATE_17H                 = 0x17,
    ATA_C_RECALIBRATE_18H                 = 0x18,
    ATA_C_RECALIBRATE_19H                 = 0x19,
    ATA_C_RECALIBRATE_1AH                 = 0x1A,
    ATA_C_RECALIBRATE_1BH                 = 0x1B,
    ATA_C_RECALIBRATE_1CH                 = 0x1C,
    ATA_C_RECALIBRATE_1DH                 = 0x1D,
    ATA_C_RECALIBRATE_1EH                 = 0x1E,
    ATA_C_RECALIBRATE_1FH                 = 0x1F,
    ATA_C_READ_SECTOR                     = 0x20,
    ATA_C_READ_SECTOR_WITHOUT_RETRY       = 0x21,
    ATA_C_READ_LONG                       = 0x22,
    ATA_C_READ_LONG_WITHOUT_RETRY         = 0x23,
    ATA_C_READ_SECTOR_EXT                 = 0x24,
    ATA_C_READ_DMA_EXT,
    ATA_C_READ_DMA_QUEUED_EXT         = 0x26,
    ATA_C_READ_NATIVE_MAX_ADDRESS_EXT = 0x27,
    ATA_C_READ_MULTIPLE_EXT           = 0x29,
    ATA_C_READ_STREAM_DMA             = 0x2A,
    ATA_C_READ_STREAM_EXT             = 0x2B,
    ATA_C_READ_LOG_EXT                = 0x2F,
    ATA_C_WRITE_SECTOR                = 0x30,
    ATA_C_WRITE_SECTOR_WITHOUT_RETRY  = 0x31,
    ATA_C_WRITE_LONG                  = 0x32,
    ATA_C_WRITE_LONG_WITHOUT_RETRY    = 0x33,
    ATA_C_WRITE_SECTOR_EXT            = 0x34,
    ATA_C_WRITE_DMA_EXT,
    ATA_C_WRITE_DMA_QUEUED_EXT            = 0x36,
    ATA_C_SET_MAX_ADDRESS_EXT             = 0x37,
    ATA_C_CFA_WRITE_SECTORS_WITHOUT_ERASE = 0x38,
    ATA_C_WRITE_MULTIPLE_EXT              = 0x39,
    ATA_C_WRITE_STREAM_DMA                = 0x3A,
    ATA_C_WRITE_STREAM_EXT                = 0x3B,
    ATA_C_WRITE_VERIFY                    = 0x3C,
    ATA_C_WRITE_DMA_FUA_EXT               = 0x3D,
    ATA_C_WRITE_DMA_QUEUED_FUA_EXT        = 0x3E,
    ATA_C_WRITE_LOG_EXT                   = 0x3F,
    ATA_C_READ_VERIFY_SECTOR              = 0x40,
    ATA_C_READ_VERIFY_SECTOR_WITHOUT_RETRY = 0x41,
    ATA_C_READ_VERIFY_SECTOR_EXT          = 0x42,
    ATA_C_ZERO_EXT                        = 0x44,
    ATA_C_WRITE_UNCORRECTABLE_EXT         = 0x45,
    ATA_C_READ_LOG_DMA_EXT                = 0x47,
    ATA_C_ZAC_MANAGEMENT_IN               = 0x4A,
    ATA_C_FORMAT_TRACK                    = 0x50,
    ATA_C_CONFIGURE_STREAM                = 0x51,
    ATA_C_WRITE_LOG_DMA_EXT               = 0x57,
    ATA_C_TRUSTED_NON_DATA                = 0x5B,
    ATA_C_TRUSTED_RECEIVE                 = 0x5C,
    ATA_C_TRUSTED_RECEIVE_DMA             = 0x5D,
    ATA_C_TRUSTED_SEND                    = 0x5E,
    ATA_C_TRUSTED_SEND_DMA                = 0x5F,
    ATA_C_READ_FPDMA_QUEUED               = 0x60,
    ATA_C_WRITE_FPDMA_QUEUED              = 0x61,
    ATA_C_SATA_62H                        = 0x62,
    ATA_C_NCQ_NON_DATA                    = 0x63,
    ATA_C_SEND_FPDMA_QUEUED               = 0x64,
    ATA_C_RECEIVE_FPDMA_QUEUED            = 0x65,
    ATA_C_SATA_66H                        = 0x66,
    ATA_C_SATA_67H                        = 0x67,
    ATA_C_SATA_68H                        = 0x68,
    ATA_C_SATA_69H                        = 0x69,
    ATA_C_SATA_6AH                        = 0x6A,
    ATA_C_SATA_6BH                        = 0x6B,
    ATA_C_SATA_6CH                        = 0x6C,
    ATA_C_SATA_6DH                        = 0x6D,
    ATA_C_SATA_6EH                        = 0x6E,
    ATA_C_SATA_6FH                        = 0x6F,
    ATA_C_SEEK                            = 0x70,
    ATA_C_SEEK_71H                        = 0x71,
    ATA_C_SEEK_72H                        = 0x72,
    ATA_C_SEEK_73H                        = 0x73,
    ATA_C_SEEK_74H                        = 0x74,
    ATA_C_SEEK_75H                        = 0x75,
    ATA_C_SEEK_76H                        = 0x76,
    ATA_C_SET_TIME_DATA_EXT               = 0x77,
    ATA_C_ACCESSIBLE_MAX_ADDRESS_CONFIGURATION = 0x78,
    ATA_C_SEEK_79H                        = 0x79,
    ATA_C_SEEK_7AH                        = 0x7A,
    ATA_C_SEEK_7BH                        = 0x7B,
    ATA_C_REMOVE_ELEMENT_AND_TRUNCATE     = 0x7C,
    ATA_C_RESTORE_ELEMENTS_AND_REBUILD    = 0x7D,
    ATA_C_SEEK_7EH                        = 0x7E,
    ATA_C_SEEK_7FH                        = 0x7F,
    ATA_C_CFA_TRANSLATE_SECTOR            = 0x87,
    ATA_C_SCE_SECURITY_CONTROL            = 0x8e,
    ATA_C_EXECUTE_DEVICE_DIAGNOSTIC       = 0x90,
    ATA_C_INITIALIZE_DEVICE_PARAMETERS    = 0x91,
    ATA_C_DOWNLOAD_MICROCODE              = 0x92,
    ATA_C_DOWNLOAD_MICROCODE_DMA          = 0x93,
    ATA_C_STANDBY_IMMEDIATE_94H           = 0x94,
    ATA_C_IDLE_IMMEDIATE_95H              = 0x95,
    ATA_C_MUTATE                          = 0x96,
    ATA_C_IDLE_97H                        = 0x97,
    ATA_C_CHECK_POWER_MODE_98H            = 0x98,
    ATA_C_SLEEP_99H                       = 0x99,
    ATA_C_ZAC_MANAGEMENT_OUT              = 0x9F,
    ATA_C_PACKET                          = 0xa0,
    ATA_C_IDENTIFY_PACKET_DEVICE,
    ATA_C_SERVICE,
    ATA_C_SMART             = 0xb0,
    ATA_C_DEVICE_CONFIGURATION,
    ATA_C_SET_SECTOR_CONFIGURATION_EXT,
    ATA_C_SANATIZE_DEVICE = 0xb4,
    ATA_C_NV_CACHE = 0xb6,
    ATA_C_CFA_KEY_MANAGEMENT = 0xb9,
    ATA_C_CFA_ERASE_SECTORS = 0xc0,
    ATA_C_READ_MULTIPLE     = 0xc4,
    ATA_C_WRITE_MULTIPLE,
    ATA_C_SET_MULTIPLE_MODE,
    ATA_C_READ_DMA_QUEUED,
    ATA_C_READ_DMA,
    ATA_C_READ_DMA_WITHOUT_RETRIES,
    ATA_C_WRITE_DMA        = 0xca,
    ATA_C_WRITE_DMA_WITHOUT_RETRIES,
    ATA_C_WRITE_DMA_QUEUED = 0xcc,
    ATA_C_CFA_WRITE_MULTIPLE_WITHOUT_ERASE,
    ATA_C_WRITE_MULTIPLE_FUA_EXT,
    ATA_C_CHECK_MEDIA_CARD_TYPE = 0xd1,
    ATA_C_GET_MEDIA_STATUS = 0xda,
    ATA_C_ACKNOWLEDGE_MEDIA_CHANGE = 0xdb,
    ATA_C_BOOT_POST_BOOT = 0xdc,
    ATA_C_BOOT_PRE_BOOT = 0xdd,
    ATA_C_MEDIA_LOCK       = 0xde,
    ATA_C_MEDIA_UNLOCK,
    ATA_C_STANDBY_IMMEDIATE = 0xe0,
    ATA_C_IDLE_IMMEDIATE,
    ATA_C_STANDBY,
    ATA_C_IDLE,
    ATA_C_READ_BUFFER,
    ATA_C_CHECK_POWER_MODE,
    ATA_C_SLEEP,
    ATA_C_FLUSH_CACHE,
    ATA_C_WRITE_BUFFER,
    ATA_C_WRITE_SAME_READ_BUFFER_DMA = 0xe9,
    ATA_C_FLUSH_CACHE_EXT = 0xea,
    ATA_C_WRITE_BUFFER_DMA = 0xeb,
    ATA_C_IDENTIFY_DEVICE = 0xec,
    ATA_C_MEDIA_EJECT,
    ATA_C_IDENTIFY_DEVICE_DMA = 0xee,

    ATA_C_SET_FEATURES = 0xef,

    ATA_C_SECURITY_SET_PASSWORD = 0xf1,
    ATA_C_SECURITY_UNLOCK,
    ATA_C_SECURITY_ERASE_PREPARE,
    ATA_C_SECURITY_ERASE_UNIT,
    ATA_C_SECURITY_FREEZE_LOCK,
    ATA_C_SECURITY_DISABLE_PASSWORD,

    ATA_C_READ_NATIVE_MAX_ADDRESS = 0xf8,
    ATA_C_SET_MAX_ADDRESS,
};

enum ATA_SCE_SECURITY_CODES {
    ATA_SCE_IDENTIFY_DRIVE = 0xec,

    ATA_SCE_SECURITY_SET_PASSWORD = 0xf1,
    ATA_SCE_SECURITY_UNLOCK,
    ATA_SCE_SECURITY_ERASE_PREPARE,
    ATA_SCE_SECURITY_ERASE_UNIT,
    ATA_SCE_SECURITY_FREEZE_LOCK,
    ATA_SCE_SECURITY_READ_ID  = 0x20,
    ATA_SCE_SECURITY_WRITE_ID = 0x30,
};

enum ATA_S_SMART_CODES {
    ATA_S_SMART_READ_DATA               = 0xd0,
    ATA_S_SMART_ENABLE_DISABLE_AUTOSAVE = 0xd2,
    ATA_S_SMART_SAVE_ATTRIBUTE_VALUES,
    ATA_S_SMART_EXECUTE_OFF_LINE,
    ATA_S_SMART_READ_LOG,
    ATA_S_SMART_WRITE_LOG,
    ATA_S_SMART_ENABLE_OPERATIONS = 0xd8,
    ATA_S_SMART_DISABLE_OPERATIONS,
    ATA_S_SMART_RETURN_STATUS
};

/** Offsets for the data returned from IDENTIFY DEVICE commands.  */
enum _ata_identify_offsets {
    ATA_ID_GENERAL_CONFIGURATION = 0,
    ATA_ID_SPECIFIC_CONFIGURATION = 2,
    ATA_ID_CFA_NUMBER_OF_SECTORS_PER_CARD_0 = 7,
    ATA_ID_CFA_NUMBER_OF_SECTORS_PER_CARD_1 = 8,
    ATA_ID_SERIAL_NUMBER_0 = 10,
    ATA_ID_SERIAL_NUMBER_1 = 11,
    ATA_ID_SERIAL_NUMBER_2 = 12,
    ATA_ID_SERIAL_NUMBER_3 = 13,
    ATA_ID_SERIAL_NUMBER_4 = 14,
    ATA_ID_SERIAL_NUMBER_5 = 15,
    ATA_ID_SERIAL_NUMBER_6 = 16,
    ATA_ID_SERIAL_NUMBER_7 = 17,
    ATA_ID_SERIAL_NUMBER_8 = 18,
    ATA_ID_SERIAL_NUMBER_9 = 19,
    ATA_ID_FIRMWARE_REVISION_0 = 23,
    ATA_ID_FIRMWARE_REVISION_1 = 24,
    ATA_ID_FIRMWARE_REVISION_2 = 25,
    ATA_ID_FIRMWARE_REVISION_3 = 26,
    ATA_ID_MODEL_NUMBER_00 = 27,
    ATA_ID_MODEL_NUMBER_01 = 28,
    ATA_ID_MODEL_NUMBER_02 = 29,
    ATA_ID_MODEL_NUMBER_03 = 30,
    ATA_ID_MODEL_NUMBER_04 = 31,
    ATA_ID_MODEL_NUMBER_05 = 32,
    ATA_ID_MODEL_NUMBER_06 = 33,
    ATA_ID_MODEL_NUMBER_07 = 34,
    ATA_ID_MODEL_NUMBER_08 = 35,
    ATA_ID_MODEL_NUMBER_09 = 36,
    ATA_ID_MODEL_NUMBER_10 = 37,
    ATA_ID_MODEL_NUMBER_11 = 38,
    ATA_ID_MODEL_NUMBER_12 = 39,
    ATA_ID_MODEL_NUMBER_13 = 40,
    ATA_ID_MODEL_NUMBER_14 = 41,
    ATA_ID_MODEL_NUMBER_15 = 42,
    ATA_ID_MODEL_NUMBER_16 = 43,
    ATA_ID_MODEL_NUMBER_17 = 44,
    ATA_ID_MODEL_NUMBER_18 = 45,
    ATA_ID_MODEL_NUMBER_19 = 46,
    ATA_ID_TRUSTED_COMPUTING_FEATURE_SET_OPTIONS = 48,
    ATA_ID_CAPABILITIES_49 = 49,
    ATA_ID_CAPABILITIES_50 = 50,
    ATA_ID_CAPABILITIES_53 = 53,
    ATA_ID_CAPABILITIES_59 = 59,
    ATA_ID_SECTOTAL_LO            = 60,
    ATA_ID_SECTOTAL_HI            = 61,
    ATA_ID_MULTIWORD_DMA_MODES    = 63,
    ATA_ID_CAPABILITIES_64        = 64,
    ATA_ID_MINIMUM_MULTIWORD_DMA_TRANSFER_CYCLE_TYPE_PER_WORD = 65,
    ATA_ID_MANUFACTURERS_RECOMMENDED_MULTIWORD_DMA_TRANSFER_CYCLE_TIME = 66,
    ATA_ID_MINIMUM_PIO_TRANSFER_CYCLE_TIME_WITHOUT_FLOW_CONTROL = 67,
    ATA_ID_MINIMUM_PIO_TRANSFER_CYCLE_TIME_WITH_IORDY_FLOW_CONTROL = 68,
    ATA_ID_ADDITIONAL_SUPPORTED = 69,
    ATA_ID_QUEUE_DEPTH = 75,
    ATA_ID_SERIAL_ATA_CAPABILITIES = 76,
    ATA_ID_SERIAL_ATA_ADDITIONAL_CAPABILITIES = 77,
    ATA_ID_SERIAL_ATA_FEATURES_SUPPORTED = 78,
    ATA_ID_SERIAL_ATA_FEATURES_ENABLED = 79,
    ATA_ID_MAJOR_VERSION_NUMBER = 80,
    ATA_ID_MINOR_VERSION_NUMBER = 81,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_82 = 82,
    ATA_ID_COMMAND_SETS_SUPPORTED = 83,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_84 = 84,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_OR_ENABLED_85 = 85,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_OR_ENABLED_86 = 86,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_OR_ENABLED_87 = 87,
    ATA_ID_UDMA_CONTROL           = 88,
    ATA_ID_TIME_REQUIRED_FOR_A_NORMAL_ERASE_MODE_SECURITY_ERASE_UNIT_COMMAND = 89,
    ATA_ID_TIME_REQUIRED_FOR_AN_ENHANCED_ERASE_MODE_SECURITY_ERASE_UNIT_COMMAND = 90,
    ATA_ID_CAPABILITIES_91 = 91,
    ATA_ID_MASTER_PASSWORD_IDENTIFIER = 92,
    ATA_ID_HARDWARE_RESET_RESULTS = 93,
    ATA_ID_STREAM_MINIMUM_REQUEST_SIZE = 95,
    ATA_ID_STREAMING_TRANSFER_TIME = 96,
    ATA_ID_STREAMING_ACCESS_LATENCY = 97,
    ATA_ID_STREAMING_PERFORMANCE_GRANULARITY_0 = 98,
    ATA_ID_STREAMING_PERFORMANCE_GRANULARITY_1 = 99,
    ATA_ID_48BIT_SECTOTAL_LO      = 100,
    ATA_ID_48BIT_SECTOTAL_MI      = 101,
    ATA_ID_48BIT_SECTOTAL_HI      = 102,
    ATA_ID_48BIT_SECTOTAL_UI      = 103,
    ATA_ID_STREAMING_TRANSFER_TIME_PIO = 104,
    ATA_ID_MAXIMUM_NUMBER_OF_512_BYTE_BLOCKS_PER_DATA_SET_MANAGEMENT_COMMAND = 105,
    ATA_ID_PHYSICAL_SECTOR_SIZE_LOGICAL_SECTOR_SIZE = 106,
    ATA_ID_INTER_SEEK_DELAY_FOR_ISO_IEC_7779_STANDARD_ACOUSTIC_TESTING = 107,
    ATA_ID_WORLD_WIDE_NAME_0 = 108,
    ATA_ID_WORLD_WIDE_NAME_1 = 109,
    ATA_ID_WORLD_WIDE_NAME_2 = 110,
    ATA_ID_WORLD_WIDE_NAME_3 = 111,
    ATA_ID_LOGICAL_SECTOR_SIZE_0 = 117,
    ATA_ID_LOGICAL_SECTOR_SIZE_1 = 118,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_119 = 119,
    ATA_ID_COMMANDS_AND_FEATURE_SETS_SUPPORTED_OR_ENABLED_120 = 120,
    ATA_ID_SECURITY_STATUS        = 128,
    ATA_ID_CFA_POWER_REQUIREMENT_DESCRIPTION = 160,
    ATA_ID_CFA_KEY_MANAGEMENT_SCHEMES_SUPPORTED = 162,
    ATA_ID_CFA_CF_ADVANCED_TRUE_IDE_TIMING_MODE_CAPABILITY_AND_SETTING = 163,
    ATA_ID_CFA_CF_ADVANCED_PC_CARD_IO_AND_MEMORY_TIMING_MODE_CAPABILITY = 164,
    ATA_ID_CAPABILITIES_168 = 168,
    ATA_ID_DATA_SET_MANAGEMENT_COMMAND_SUPPORT = 169,
    ATA_ID_ADDITIONAL_PRODUCT_IDENTIFIER_0 = 170,
    ATA_ID_ADDITIONAL_PRODUCT_IDENTIFIER_1 = 171,
    ATA_ID_ADDITIONAL_PRODUCT_IDENTIFIER_2 = 172,
    ATA_ID_ADDITIONAL_PRODUCT_IDENTIFIER_3 = 173,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_00 = 176,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_01 = 177,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_02 = 178,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_03 = 179,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_04 = 180,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_05 = 181,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_06 = 182,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_07 = 183,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_08 = 184,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_09 = 185,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_10 = 186,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_11 = 187,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_12 = 188,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_13 = 189,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_14 = 190,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_15 = 191,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_16 = 192,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_17 = 193,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_18 = 194,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_19 = 195,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_20 = 196,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_21 = 197,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_22 = 198,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_23 = 199,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_24 = 200,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_25 = 201,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_26 = 202,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_27 = 203,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_28 = 204,
    ATA_ID_CURRENT_MEDIA_SERIAL_NUMBER_29 = 205,
    ATA_ID_SCT_COMMAND_TRANSPORT = 206,
    ATA_ID_ALIGNMENT_OF_LOGICAL_SECTORS_WITHIN_A_PHYSICAL_SECTOR = 209,
    ATA_ID_WRITE_READ_VERIFY_SECTOR_MODE_3_COUNT_0 = 210,
    ATA_ID_WRITE_READ_VERIFY_SECTOR_MODE_3_COUNT_1 = 211,
    ATA_ID_WRITE_READ_VERIFY_SECTOR_MODE_2_COUNT_0 = 212,
    ATA_ID_WRITE_READ_VERIFY_SECTOR_MODE_2_COUNT_1 = 213,
    ATA_ID_NOMINAL_MEDIA_ROTATION_RATE = 217,
    ATA_ID_CAPABILITIES_220 = 220,
    ATA_ID_TRANSPORT_MAJOR_VERSION_NUMBER = 222,
    ATA_ID_TRANSPORT_MINOR_VERSION_NUMBER = 223,
    ATA_ID_EXTENDED_NUMBER_OF_USER_ADDRESSABLE_SECTORS_0 = 230,
    ATA_ID_EXTENDED_NUMBER_OF_USER_ADDRESSABLE_SECTORS_1 = 231,
    ATA_ID_EXTENDED_NUMBER_OF_USER_ADDRESSABLE_SECTORS_2 = 232,
    ATA_ID_EXTENDED_NUMBER_OF_USER_ADDRESSABLE_SECTORS_3 = 233,
    ATA_ID_MINIMUM_NUMBER_OF_512_BYTE_DATA_BLOCKS_PER_DOWNLOAD_MICROCODE_OPERATION = 234,
    ATA_ID_MAXIMUM_NUMBER_OF_512_BYTE_DATA_BLOCKS_PER_DOWNLOAD_MICROCODE_OPERATION = 235,
    ATA_ID_INTEGRITY_WORD = 255,
};

/* Bits in the security status word.  */
#define ATA_F_SEC_ENABLED (1 << 1)
#define ATA_F_SEC_LOCKED  (1 << 2)

#endif /* __ATAHW_H__ */
